﻿//===============================================================================================
//author:     UnKnow
//create date:   UnKnow
//Description: BllPayAndReceiveItem And Validation Class[Get And Rewrite by Zeinali,Farshad]
//Email :  farshadz70@gmail.com
//Mobile: 0912_6467348
//LastUpdate:  1390/02/23 23:46
//Important:   Lotfan kasi bedon hamahangi man Class ro taghir nade
//===============================================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChequeManagement.BLL
{
    /// <summary>
    /// This Class contains number of Field,properties,method, enum that Inheritance of "BaseObject" Class
    /// </summary>
    /// <properties>this properties contain set for receive value and contain get for return value</properties>
    /// <method>this class contain IsValid method for Validation all properties</method>
    /// <enum>this enum contain  AcountNo, Amount, BranchName, BankID, ChequeNo, DateOfIssue, Description, Payee, PayAndReceiveID, Status</enum>
    public class BLLPayAndReceiveItem : BaseObject
    {
        #region Field
        /// <summary>
        /// this enum contain some member
        /// </summary>
        public enum PayAndReceiveItemField
        {
            AcountNo, Amount, BranchName, BankID, ChequeNo, DateOfIssue, Description, Payee, PayAndReceiveID, Status
        }

        private long? acountNo;
        private decimal? amount;
        private string branchName;
        private long? chequeNo;
        private DateTime? dateOfIssue;
        private string description;
        private string payee;

        //user can't fill this directly
        private int? payAndReceiveID;

        private ChequeStatus status;

        //it only use for get from database. user can't fill it directly
        private int? bankID;
        //user fill this
        private BLLBank bankObject;


        #endregion

        #region Counstractor
        /// <summary>
        ///This constructor not have parameter and use on create instance of class
        /// </summary>
        public BLLPayAndReceiveItem()
        {
        }

        /// <summary>
        /// This constructor have parameters and use on create instance of class
        /// </summary>
        /// <param name="chequeNo" Type="long"></param>
        /// <param name="acountNo" Type="long"></param>
        /// <param name="bankObject" Type="BLL.BLLBank"></param>
        /// <param name="amount" Type="decimal"></param>
        /// <param name="dateOfIssue" Type="DateTime"></param>
        /// <param name="branchName" Type="string"></param>
        /// <param name="payee" Type="string"></param>
        /// <param name="status" Type="ChequeStatus">"ChequeStatus" parameter type is enum </param>
        /// <param name="payAndReceiveID" Type="int"></param>
        public BLLPayAndReceiveItem(long chequeNo, long acountNo, BLL.BLLBank bankObject, decimal amount, DateTime dateOfIssue, string branchName, string payee, ChequeStatus status, int payAndReceiveID)
        {
            this.chequeNo = chequeNo;
            this.acountNo = acountNo;
            this.bankObject = bankObject;
            this.amount = amount;
            this.dateOfIssue = dateOfIssue;
            this.branchName = branchName;
            this.payee = payee;
            this.status = status;
            this.payAndReceiveID = payAndReceiveID;
        }



        #endregion

        #region Property
        /// <summary>
        ///  This property contain set for receive value and contain get for return value
        /// </summary>
        public long? AcountNo
        {
            get
            {
                return acountNo.Value;
            }
            set
            {

                acountNo = value;
            }
        }

        /// <summary>
        /// This property contain set for receive value and contain get for return value
        /// </summary>
        public long? ChequeNo
        {
            get
            {
                return chequeNo.Value;
            }
            set
            {
                chequeNo = value;
            }

        }

        /// <summary>
        ///  This property contain set for receive value and contain get for return value
        /// </summary>
        public decimal? Amount
        {
            get
            {
                return amount.Value;
            }
            set
            {
                amount = value;
            }
        }

        /// <summary>
        /// This property contain set for receive value and contain get for return value
        /// </summary>
        public string BranchName
        {
            get
            {
                return branchName;
            }
            set
            {
                branchName = value;
            }
        }

        /// <summary>
        /// This property contain set for receive value and contain get for return value
        /// </summary>
        public int BankID
        {
            get
            {
                return bankID.Value;
            }
            set
            {
                bankID = value;
            }
        }

        //public BLL.BLLBank BankObject
        //{
        //    get
        //    {
        //        return bankObject;
        //    }
        //    set
        //    {
        //        bankObject = value;
        //    }
        //}

        /// <summary>
        /// This property contain set for receive value and contain get for return value
        /// </summary>
        public DateTime? DateOfIssue
        {
            get
            {
                return dateOfIssue.Value;
            }
            set
            {
                dateOfIssue = value;
            }
        }

        /// <summary>
        /// This property contain set for receive value and contain get for return value
        /// </summary>
        public string Description
        {
            get
            {
                return description;
            }
            set
            {
                description = value;
            }
        }

        /// <summary>
        /// This property contain set for receive value and contain get for return value
        /// </summary>
        public string Payee
        {
            get
            {
                return payee;
            }
            set
            {
                payee = value;
            }
        }

        /// <summary>
        /// This property contain set for receive value and contain get for return value
        /// </summary>
        /// <ChequeStatus>ChequeStatus type is enum that declare on Enums.cs and contain some member</ChequeStatus>
        public ChequeStatus Status
        {
            get
            {
                return status;
            }
            set
            {
                status = value;
            }
        }

        /// <summary>
        ///  This property contain set for receive value and contain get for return value
        /// </summary>
        public int PayAndReceiveID
        {
            get
            {
                return payAndReceiveID.Value;
            }
            set
            {
                payAndReceiveID = value;
            }
        }

        #endregion

        #region Method
        /// <summary>
        /// This method check fields value
        /// </summary>
        /// <acountNo>if acountNo value is null this method add error</acountNo>
        /// <chequeNo>if chequeNo value is null this method add error</chequeNo>
        /// <branchName>if branchName length value without space is zero this method add error</branchName>
        /// <dateOfIssue>if dateOfIssue value is null this method add error</dateOfIssue>
        /// <description>if description length value without space is zero this method add error</description>
        /// <payee>if payee length value without space is zero this method add error</payee>
        /// <payAndReceiveID>if payAndReceiveID value is null this method add error</payAndReceiveID>
        /// <returns>if all field is Valid,ErrorsCount value is zero and return true else ErrorsCount value Larger of zero return false</returns>
        public bool IsValid()
        {
            if (!acountNo.HasValue)
                AddError("شماره حساب وارد نشده است", null);
            else
            {
            }

            if (!chequeNo.HasValue)
            {
                AddError("شماره چک نمی تواند خالی باشد", null);
            }
            else
            {
            }
            if (branchName.Trim().Length == 0)
            {
                AddError("نام شعبه می تواند خالی باشد", null);
            }
            else
            {

            }
            if (!dateOfIssue.HasValue)
            {
                AddError("تاریخ چک نمی تواند خالی باشد", null);
            }
            else
            {
            }
            if (description.Trim().Length == 0)
            {
                AddError("توضیحات چک نمی تواند خالی باشد", null);
            }
            else
            {
            }
            if (payee.Trim().Length == 0)
            {
                AddError("نام گیرنده نمی تواند خالی باشد", null);
            }
            else
            {
            }
            if (!payAndReceiveID.HasValue)
            {
                AddError("ابتدا باید فرم محل پرداخت را ثبت کنید", null);
            }
            else
            {
            }

            if (ErrorsCount > 0)
                return false;
            else
                return true;
        }
        #endregion


    }
}
